package com.study.hospital_3.controller;

import com.study.hospital_3.pojo.Doctor;
import com.study.hospital_3.service.impl.DoctorServiceImpl;
import com.study.hospital_3.vo.DoctorUpdateVO;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
import io.swagger.annotations.Api;

import javax.annotation.Resource;

/**
 * (Doctor)表控制层
 *
 * @author Drifter
 * @since 2025-01-18 23:23:49
 */
@RestController
@RequestMapping("doctor")
@Api(value = "(Doctor)",tags = "(Doctor)接口API")
public class DoctorController {
    /**
     * 服务对象
     */
    @Resource
    private DoctorServiceImpl doctorServiceImpl;

    /**
     * 一次性全部查询
     *
     * @return 查询结果
     */
    @GetMapping("/selectAll")
    public Map<String, Object> selectAll(DoctorUpdateVO doctorUpdateVO) {
        return doctorServiceImpl.selectAll(doctorUpdateVO);
    }

    /**
     * 分页查询
     *
     * @param doctor 筛选条件
     * @param page        要查询第几页
     * @param limit       每页显示多少条
     * @return 查询结果
     */
    @GetMapping("/selectByLimit")
    public Map<String, Object> selectByLimit(Doctor doctor, @RequestParam int page, @RequestParam int limit) {
        return doctorServiceImpl.selectByLimit(doctor, page, limit);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("/selectById")
    public Map<String, Object> selectById(@RequestParam Integer id) {
        return doctorServiceImpl.selectById(id);
    }

    /**
     * 新增数据
     *
     * @param doctor 实体
     * @return 新增结果
     */
    @PostMapping("/insert")
    public Map<String, Object> insert(@RequestBody Doctor doctor) {
        return doctorServiceImpl.insert(doctor);
    }

    /**
     * 编辑数据
     *
     * @param doctorUpdateVO 实体
     * @return 编辑结果
     */
    @PostMapping ("/updateById")
    public Map<String, Object> updateById(@RequestBody DoctorUpdateVO doctorUpdateVO) {
        return doctorServiceImpl.updateById(doctorUpdateVO);
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @PostMapping("/deleteById")
    public Map<String, Object> deleteById(@RequestParam Integer id) {
        return doctorServiceImpl.deleteById(id);
    }

    @GetMapping("/selectAllT")
    public Map<String, Object> selectAllT(DoctorUpdateVO doctorUpdateVO) {
        return doctorServiceImpl.selectAllT(doctorUpdateVO);
    }

}

